package com.qinglei.recoup.system.controller;

import com.qinglei.recoup.common.domain.CommonRes;
import com.qinglei.recoup.common.tenant.TenantContextHolder;
import com.qinglei.recoup.system.pojo.TourStatusVO;
import com.qinglei.recoup.system.service.TourLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Api(tags = "巡视相关控制器-张-已完成")
@Slf4j
@Validated
@RestController
@RequestMapping("tour")
public class TourController {

    @Resource
    private TourLogService tourLogService;

    @ApiOperation(value = "护工和院长首页 获取巡视时间表接口-实现")
    @GetMapping("/listStatus")
    public CommonRes<List<TourStatusVO>> getListWithStatus() {
        Integer tenantId = TenantContextHolder.getTenantId();
        if (tenantId == null) {
            return CommonRes.ok(new ArrayList<>());
        }
        return tourLogService.getListWithStatus();
    }

    @ApiOperation(value = "护工首页 完成巡视接口-实现")
    @PutMapping
    public CommonRes succeedTour(@RequestParam String time) {
        return tourLogService.succeedTour(time);
    }

}
